﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MySql.Data.MySqlClient;

namespace AioNightly.Dao
{
    public class DBConnect
    {
        private MySqlConnection m_conn;
        private string connStr = "server=localhost;user=aio;database=build;port=3306;password=aio;";

        public MySqlConnection Conn
        {
            get { return m_conn; }
        }

        public bool OpenConnection()
        {
            if (m_conn==null)
            {
                try
                {
                    m_conn = new MySqlConnection(connStr);
                    m_conn.Open();

                    return true;
                }
                catch (MySqlException ex)
                {
                    Console.WriteLine(ex);
                    return false;
                }
            }
            return true;
        }

        public bool CloseConnection()
        {
            if (m_conn != null && m_conn.State != System.Data.ConnectionState.Closed)
            {
                m_conn.Close();
            }
            return true;
        }
    }
}